package com.epro.dx.task;

import android.os.AsyncTask;

import com.epro.dx.listenner.CustomAsyncTaskListener;
import com.epro.dx.util.ActivityUtil;
import com.weipu.common.facade.factory.ProviderFactory;

/**
 * 保存用户配置的推送配置
 * @author Zenglw
 * @version [1.0]
 * @date 2017-6-23
 * @see [相关类/方法]
 *
 */
public class SetShippingMsgSettingTask extends AsyncTask<Void,Void,Boolean> {
    private int CycleSetType;
    private boolean isPush;
    private int pushType;
    private int pushCircle;
    private CustomAsyncTaskListener<Boolean> mListener;

    public SetShippingMsgSettingTask(boolean isPush,int pushType,int pushCircle,int CycleSetType,CustomAsyncTaskListener<Boolean> listener) {
        this.isPush  = isPush;
        this.pushType = pushType;
        this.pushCircle = pushCircle;
        this.CycleSetType = CycleSetType;
        this.mListener = listener;
    }

    @Override
    protected Boolean doInBackground(Void... params) {
        /**
         *
         * 请求方式：
            POST
         CustomerID	Long	用户ID	Y
         Token	String	Token，安全校验	Y
         IsPush	Bool	是否推送	Y	True:是  False:否
         PushType	Int	推送类型	Y	1:直接推送
         2:周期推送
         PushCycle	Int	周期天数	N	大于0的正整数
         */
        return ProviderFactory.createTrackService().saveTrackConfig(ActivityUtil.getCustomerID(),ActivityUtil.getCustomerToken(),isPush,pushType,pushCircle,CycleSetType);
    }

    @Override
    protected void onPostExecute(Boolean isSuccess) {
        super.onPostExecute(isSuccess);
        if (mListener != null) {
            mListener.onPostExecute(isSuccess);
        }
    }
}
